package com.itlong.cloud.property;

import com.itlong.cloud.iottp.IIotVisitorFaceServiceClient;
import com.itlong.cloud.user.property.IPropertyVisitorServiceClient;
import com.itlong.cloud.utils.date.DateUtil;
import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RestController;

import java.util.Calendar;

/**
 * <desc>
 *      过期访客人脸删除结果任务调度类
 * </desc>
 *
 * @createDate 2019/03/04
 */
@EnableScheduling // 启用定时任务
@RestController
public class VisitorFaceDeleteTimeTask {
    private static Logger LOG = LoggerFactory.getLogger(VisitorFaceDeleteTimeTask.class);

    @Autowired
    IIotVisitorFaceServiceClient iIotVisitorFaceServiceClient;

    /**
     * <desc>
     *      过期访客人脸删除结果表
     * </desc>
     *
     * @author Qiang.S
     * @creatDate 2019/03/04
     */
    @Scheduled(cron = "0 0 * * * ?") // 每小时执行一次
//    @Scheduled(cron = "0/5 * * * * ?") // 每30秒执行一次
    public void timeTaskSychro() {
        try {
            iIotVisitorFaceServiceClient.visitorFaceDelete();
//            LOG.info("【定时任务】过期访客人脸删除结果表执行成功，当前时间：" + DateUtil.format(Calendar.getInstance(), "yyyy-MM-dd HH:mm:ss"));
        }catch (Exception e){
            LOG.error("【定时任务】过期访客人脸删除结果表执行失败，当前时间：" + DateUtil.format(Calendar.getInstance(), "yyyy-MM-dd HH:mm:ss:"),e);
        }
    }
}
